package com.ybkj.chat.module.mine.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author yyj
 * @create 2019-02-21 11:01
 * @Describe
 */
public class MultiUseActivity extends BaseMvpActivity {

    @BindView(R.id.lnl_account_safe)
    LinearLayout lnlAccountSafe;
    @BindView(R.id.lnl_message_notice)
    LinearLayout lnlMessageNotice;
    @BindView(R.id.lnl_privacy)
    LinearLayout lnlPrivacy;
    @BindView(R.id.lnl_reset_psd1)
    LinearLayout lnlResetPsd1;
    @BindView(R.id.lnl_modify_phone)
    LinearLayout lnlModifyPhone;
    @BindView(R.id.tv_bind_phone)
    TextView tvBindPhone;
    @BindView(R.id.tv_unbind_phone)
    TextView tvUnbindPhone;
    @BindView(R.id.lnl_bind_phone)
    LinearLayout lnlBindPhone;
    @BindView(R.id.lnl_distance_privacy1)
    LinearLayout lnlDistancePrivacy1;

    private String title = "";
    private String type = "";// 1已绑定  2未绑定


    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initTitle() {
        setTitleText(title);
        if (title.equals("手机绑定") && "2".equals(type)) {
            setRightText("提交");
            setRightTextColor(R.color.color_dfd);
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_multiuse;
    }

    @Override
    protected void initView() {
        title = getIntent().getStringExtra("title");
        type = getIntent().getStringExtra("type");
    }

    @Override
    protected void initData() {
        if ("账号安全".equals(title)) {
            lnlAccountSafe.setVisibility(View.VISIBLE);
        } else if ("消息通知".equals(title)) {
            lnlMessageNotice.setVisibility(View.VISIBLE);
        } else if ("隐私设置".equals(title)) {
            lnlPrivacy.setVisibility(View.VISIBLE);
        } else if ("重置密码".equals(title)) {
            lnlResetPsd1.setVisibility(View.VISIBLE);
        } else if ("距离隐私".equals(title)) {
            lnlDistancePrivacy1.setVisibility(View.VISIBLE);
        } else if ("手机绑定".equals(title)) {
            if ("1".equals(type)) {
                lnlModifyPhone.setVisibility(View.VISIBLE);
            } else {
                lnlBindPhone.setVisibility(View.VISIBLE);
            }

        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.lnl_reset_psd, R.id.lnl_bind_phone1, R.id.lnl_modify_phone, R.id.lnl_distance_privacy,R.id.lnl_black_list})
    public void onViewClicked(View view) {
        Intent intent = new Intent(this, MultiUseActivity.class);
        switch (view.getId()) {
            case R.id.lnl_reset_psd:
                intent.putExtra("title", "重置密码");
                break;
            case R.id.lnl_bind_phone1:
                intent.putExtra("title", "手机绑定");
                if (tvBindPhone.getVisibility() == View.VISIBLE) {
                    intent.putExtra("type", "1");
                }
                if (tvUnbindPhone.getVisibility() == View.VISIBLE) {
                    intent.putExtra("type", "2");
                }
                break;
            case R.id.lnl_modify_phone:
                intent.putExtra("title", "手机绑定");
                intent.putExtra("type", "2");
                break;
            case R.id.lnl_distance_privacy:
                intent.putExtra("title", "距离隐私");
                break;
            case R.id.lnl_black_list:
                intent = new Intent(this,BlackListActivity.class);
                break;
        }
        startActivity(intent);

    }
}
